from Products.CMFCore.utils import getToolByName

def registerTransform(portal):
    transforms = getToolByName(portal, 'portal_transforms')
    if transforms.get('pdf_to_flash') == None:
        transforms.manage_addTransform('pdf_to_flash',
                                       'collective.transform.pdf2swf.transforms.pdf_to_flash')
    
def importVarious(context):
    """Miscellanous steps import handle
    """
    
    # Ordinarily, GenericSetup handlers check for the existence of XML files.
    # Here, we are not parsing an XML file, but we use this text file as a 
    # flag to check that we actually meant for this import step to be run.
    # The file is found in profiles/default.
    
    if context.readDataFile('collective.transform.pdf2swf_various.txt') is None:
        return
    
    portal = context.getSite()
    
    registerTransform(portal)
